﻿using System;

namespace ch10.binary
{
    public static class Math
    {
        public static bool IsInf(double f, int sign)
        {
            // Test for infinity by comparing against maximum float.
            // To avoid the floating-point hardware, could use:
            //	x := Float64bits(f);
            //	return sign >= 0 && x == uvinf || sign <= 0 && x == uvneginf;
            return sign >= 0 && f > double.MaxValue || sign <= 0 && f < double.MinValue;
        }

        public static void Append<T>(ref T[] objects, T last)
        {
            Array.Resize(ref objects, objects.Length + 1);
            objects[^1] = last;
        }
    }
}